<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>在线管理</title>
<script type="text/javascript">
	var $grid;
	$(function() {
		$grid = $("#grid").datagrid({
			method : "get",
			url : "${ctx}/basic/sessions/dataGrid",
			idField : 'id',
			remoteSort : true,
			multiSort : true,
			rownumbers : true,
			fit : true,
			toolbar : '#tt',
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'host',
				title : 'IP'
			}, {
				field : 'trueName',
				title : '登录者'
			}, {
				field : 'loginName',
				title : '登录者账号'
			}, {
				field : 'deptName',
				title : '部门名称'
			}, {
				field : 'onlineStatus',
				title : '在线状态'
			}, {
				field : 'isRunas',
				title : '身份切换中'
			}, {
				field : 'startTime',
				title : '登录时间'
			}, {
				field : 'lastAccessTime',
				title : '上次访问时间'
			}, {
				field : 'stopTime',
				title : '退出时间'
			}, {
				field : 'sessionId',
				title : 'Session ID'
			}, {
				field : 'userAgent',
				title : 'userAgent'
			} ] ],
			enableHeaderClickMenu : true, //此属性开启表头列名称右侧那个箭头形状的鼠标左键点击菜单
			enableHeaderContextMenu : true, //此属性开启表头列名称右键点击菜单
			enableRowContextMenu : false
		});

		$("#forceOut").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (rowData == null) {
				$.messager.show({
					msg : "您未选中行，无法操作",
					icon : "warning",
					position : "bottomRight"
				});
			} else {
				$.messager.confirm("您确定要将[" + rowData.trueName + "]强制退出吗？", function(c) {
					if (c) {
						$.get("${ctx}/basic/sessions/" + rowData.sessionId + "/forceLogout", function(result) {
							$.messager.show({
								msg : result.msg,
								icon : "info",
								position : "bottomRight"
							});
							if (result.success) {
								$grid.datagrid("load");
							}
						}, 'json');
					}
				});
			}
		});
	});
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="row" >
	<div class="col-md-12">
	<button id="forceOut" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-log-out"></span> 强制退出
				</button>
	</div>
	</div>
</body>
</html>
